import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import px2rem from 'postcss-px2rem'
export default defineConfig({
  plugins: [vue()],
  base: './',
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  css: {
    postcss: {
      plugins: [
        px2rem({
          remUnit: 18,       // 1rem=16px
          propList: ['*'],   // 对所有属性转换
          mediaQuery: true,  // 允许媒体查询中转换px
          minPixelValue: 2,  // 小于2px不转换
          exclude: /node_modules\/element-ui/
        })
      ]
    }
  },
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    emptyOutDir: true,
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html')
      }
    }
  },
  server: {
    port: 5173
  }
}) 